package com.huawei.appgallery.purchasehistory.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.ui.framework.widget.LineImageView;
import com.huawei.appgallery.productpurchase.api.ProductDetailBean;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Locale;
import o.azb;
import o.cij;
import o.cst.d;
import o.cst.h;
import o.dof;
import o.emz;
import o.eqx;
import o.evx;

public class ProductAdapter extends BaseAdapter implements cij {
    private int hasNext;
    private Context mContext;
    private LayoutInflater mInflater;
    private List<ProductDetailBean> mProductOrderInfos;

    static class e {
        RelativeLayout ˊ;
        View ˋ;
        LineImageView ˎ;
        TextView ˏ;
        TextView ॱ;

        e(View view) {
            this.ˎ = (LineImageView) view.findViewById(o.cst.e.ˏˏ);
            this.ˏ = (TextView) view.findViewById(o.cst.e.ˎˏ);
            this.ॱ = (TextView) view.findViewById(o.cst.e.ॱʽ);
            this.ˊ = (RelativeLayout) view.findViewById(o.cst.e.ˏˎ);
            this.ˋ = view.findViewById(o.cst.e.ͺॱ);
        }
    }

    public ProductAdapter(Context context, List<ProductDetailBean> list, int i) {
        this.mProductOrderInfos = list;
        this.mInflater = LayoutInflater.from(context);
        this.mContext = context;
        this.hasNext = i;
    }

    public int getCount() {
        return this.mProductOrderInfos == null ? 0 : this.mProductOrderInfos.size();
    }

    public ProductDetailBean getItem(int i) {
        return (ProductDetailBean) this.mProductOrderInfos.get(i);
    }

    public long getItemId(int i) {
        return (long) i;
    }

    public void setHasNext(int i) {
        this.hasNext = i;
    }

    public View getView(int i, View view, ViewGroup viewGroup) {
        e eVar;
        if (view == null) {
            view = this.mInflater.inflate(d.ˏॱ, null);
            azb.ˏ(view);
            e eVar2 = new e(view);
            view.setTag(eVar2);
            eVar = eVar2;
        } else {
            eVar = (e) view.getTag();
        }
        final ProductDetailBean productDetailBean = (ProductDetailBean) this.mProductOrderInfos.get(i);
        CharSequence ꓸ = productDetailBean.ꓸ();
        TextView textView = eVar.ˏ;
        if (dof.ˋ(ꓸ)) {
            ꓸ = "--";
        }
        textView.setText(ꓸ);
        eVar.ॱ.setText(String.format(Locale.ENGLISH, this.mContext.getResources().getString(h.ॱᐝ), new Object[]{millsToDate(productDetailBean.ﾟ())}));
        eqx.ˏ(eVar.ˎ, productDetailBean.ﹳ(), "image_default_icon");
        eVar.ˊ.setOnClickListener(new evx(this) {
            final /* synthetic */ ProductAdapter ˏ;

            public void ˋ(View view) {
                emz.ˊ(this.ˏ.mContext, productDetailBean.ʹ());
            }
        });
        setDivideLine(i, eVar.ˋ);
        return view;
    }

    private void setDivideLine(int i, View view) {
        if (view != null) {
            if (i == getCount() - 1) {
                view.setVisibility(8);
            } else {
                view.setVisibility(0);
            }
        }
    }

    public boolean hasMore() {
        return this.hasNext == 1;
    }

    private String millsToDate(long j) {
        if (j < 0) {
            return "";
        }
        return new SimpleDateFormat("yyyy/MM/dd").format(Long.valueOf(j));
    }
}
